/*
 * @Author: Baishui
 * @Date: 2021-10-03 16:41:45
 * @LastEditors: Baishui
 * @LastEditTime: 2021-10-08 12:10:45
 * @Description: file content
 */
import { MockMethod } from 'vite-plugin-mock'
import { resultSuccess } from '../util'
import { Random } from 'mockjs'

const companyArr = [
  '比亚迪股份有限公司',
  '康佳集团股份有限公司',
  '海能达通信股份有限公司',
  '深圳洪涛集团股份有限公司',
  '深圳巴士集团股份有限公司',
  '深圳市水务（集团）有限公司',
  '方大集团股份有限公司',
  '深圳市雷诺表业有限公司',
  '深圳广田集团股份有限公司',
  '深圳长江家具有限公司',
  '深圳迈瑞生物医疗电子股份有限公司',
]

const basicTreeData = {
  name: Random.cname(),
  id: Random.id(),
  children: [
    {
      name: Random.cname(),
      value: '34%',
      id: Random.id(),
      children: [
        {
          name: Random.cname(),
          value: '34%',
          id: Random.id(),
        },
        {
          name: Random.cname(),
          value: '34%',
          id: Random.id(),
        },
      ],
    },
    {
      name: Random.cname(),
      value: '34%',
      id: Random.id(),
      children: [
        {
          name: Random.cname(),
          value: '34%',
          id: Random.id(),
        },
        {
          name: Random.cname(),
          value: '26%',
          id: Random.id(),
        },
        {
          name: Random.cname(),
          value: '48%',
          id: Random.id(),
        },
      ],
    },
    {
      name: Random.cname(),
      value: '34%',
      id: Random.id(),
    },
    {
      name: Random.cname(),
      value: '34%',
      id: Random.id(),
    },
    {
      name: Random.cname(),
      value: '34%',
      id: Random.id(),
      children: [
        {
          name: Random.cname(),
          value: '34%',
          id: Random.id(),
        },
      ],
    },
    {
      name: Random.cname(),
      value: '34%',
      id: Random.id(),
    },
  ],
}

const customTreeData = {
  top: {
    name: companyArr[Random.integer(0, companyArr.length - 1)],
    id: Random.id(),
    children: [
      {
        name: companyArr[Random.integer(0, companyArr.length - 1)],
        value: `${Random.integer(1, 99)}%`,
        id: Random.id(),
      },
      {
        name: companyArr[Random.integer(0, companyArr.length - 1)],
        value: `${Random.integer(1, 99)}%`,
        id: Random.id(),
      },
    ],
  },
  bottom: {
    name: companyArr[Random.integer(0, companyArr.length - 1)],
    id: Random.id(),
    children: [
      {
        name: companyArr[Random.integer(0, companyArr.length - 1)],
        value: `${Random.integer(1, 99)}%`,
        id: Random.id(),
      },
      {
        name: companyArr[Random.integer(0, companyArr.length - 1)],
        value: `${Random.integer(1, 99)}%`,
        id: Random.id(),
      },
      {
        name: companyArr[Random.integer(0, companyArr.length - 1)],
        value: `${Random.integer(1, 99)}%`,
        id: Random.id(),
      },
      {
        name: companyArr[Random.integer(0, companyArr.length - 1)],
        value: `${Random.integer(1, 99)}%`,
        id: Random.id(),
      },
      {
        name: companyArr[Random.integer(0, companyArr.length - 1)],
        value: `${Random.integer(1, 99)}%`,
        id: Random.id(),
      },
      {
        name: companyArr[Random.integer(0, companyArr.length - 1)],
        value: `${Random.integer(1, 99)}%`,
        id: Random.id(),
      },
    ],
  },
}

export default [
  {
    url: '/chart/basicTreeData',
    timeout: 200,
    method: 'post',
    response: () => {
      return resultSuccess(basicTreeData)
    },
  },
  {
    url: '/chart/customTreeData',
    timeout: 200,
    method: 'post',
    response: () => {
      return resultSuccess(customTreeData)
    },
  },
] as MockMethod[]
